# 类
class Employee:
    # 声明私有属性 __ 两个下划线,实例对象不能访问私有变量
    __privateField = "111"
    # 类变量
    empCount = 0

    # 构造方法 局部变量 name, salary
    def __init__(self, name, salary):
        self.name = name
        self.salary = salary

    # 显示类属性
    def display(self):
        print("empCount的值是: ", Employee.empCount)
        print("__privateField: ", self.__privateField)

    def displayEmploy(self):
        print(self.name, "   ", self.salary)

    def displayCustom(self, args1, args2):
        print("第一个参数是%s,第二个参数是%s" % (args1, args2))

    def rewriteFunction(self):
        print("我是父类待重写的方法")

    @classmethod
    def classFunction(self):
        print("我是类方法")


# 创建一个对象
emp = Employee("名称", 10000)
emp.empCount = 2
emp.displayEmploy()
emp.display()
# 添加、修改、删除类属性
emp.age = 20
# 自定义传参
emp.happy = "111爱好"
emp.displayCustom(111, 222)

Employee.classFunction()


#  继承操作
class Emp(Employee):
    children = ''

    # 子类的构造函数，包含父类的构造函数
    def __init__(self, name, slary, children):
        Employee.__init__(self, name, slary)
        self.children = children

    def childrenFunction(self):
        print("第一参数: %s,第二参数: %d, 第三参数: %s" % (self.name, self.salary, self.children))

    def rewriteFunction(self):
        print("我重写了父类待重写的方法")


if __name__ == '__main__':
    emp = Emp("name", 3000, "childern")
    emp.childrenFunction()
    # 子类重写父类待重写的方法
    emp.rewriteFunction()
    # 通过子类调用父类待被子类重写的方法
    super(Emp, emp).rewriteFunction()
